<?php

namespace app\common\validate;

use think\Validate;

class Classes extends Validate
{

    /**
     * 验证规则
     */
    protected $rule = [
        'name' => 'require|unique:Classes,name^grade_id^school_id',
        'school_id' => 'require',
        'classroom_id' => 'require',
        'headmaster' => 'require'
    ];

    /**
     * 提示消息
     */
    protected $message = [
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add' => ['name', 'school_id', 'classroom_id', 'headmaster'],
        'edit' => ['name' => 'require|unique:Classes,name^grade_id^id', 'school_id', 'classroom_id', 'headmaster'],
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'name' => __('名称'),
            'school_id' => __('学校'),
            'classroom_id' => __('教师'),
            'headmaster' => __('班主任'),
        ];
        parent::__construct($rules, $message, $field);
    }

}
